from planner.models import TripUser

class TripUserAuthenticationBackend(object):
    def authenticate(self, username=None, password=None):
        try:
            person = TripUser.objects.get(username=username)
            if person.check_password(password):
                return person
        except TripUser.DoesNotExist:
            pass

        return None

    def get_user(self, user_id):
        try:
            return TripUser.objects.get(pk=user_id)
        except TripUser.DoesNotExist:
            return None